package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.WxPublicNumMapper;
import com.jic.manager.entity.WxPublicNum;
import com.jic.conf.request.WxPublicNumRequest;
import com.jic.manager.service.WxPublicNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 微信公众号配置
 * @author : 
 * @email : 
 * @since : 2020-02-16 12:01:15
 * @version : v1.0.0
 */
@Service
public class WxPublicNumServiceImpl implements WxPublicNumService {

    @Autowired
    private WxPublicNumMapper wxPublicNumMapper;

    @Override
    public long insert(WxPublicNumRequest wxPublicNumRequest) {
        long flag = wxPublicNumMapper.insert(wxPublicNumRequest);
        return flag;
    }

    @Override
    public long delete(WxPublicNum id) {
        return wxPublicNumMapper.delete(id);
    }

    @Override
    public long update(WxPublicNumRequest wxPublicNumRequest) {
        return wxPublicNumMapper.update(wxPublicNumRequest);
    }

    @Override
    public WxPublicNum queryByPrimaryKey(Long id){
        return wxPublicNumMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<WxPublicNum> query(WxPublicNum wxPublicNum){
        return wxPublicNumMapper.query(wxPublicNum);
    }

    @Override
    public PageResult<WxPublicNum> queryPage(WxPublicNum wxPublicNum, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<WxPublicNum> list = wxPublicNumMapper.queryPage(startIndex, pageQuery.getLimit(), wxPublicNum);
        long count = wxPublicNumMapper.queryPageCount(wxPublicNum);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}